package com.bdqn.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/emp")
public class EmpController {

    @PostMapping("/login")
    public  String login(String  account, String password, Model model, HttpSession session){
            if ("admin".equals(account)&&"111111".equals(password)){
                session.setAttribute("loginAccount",account);
                return  "redirect:/index.html";
            }

        model.addAttribute("login_error","login.msg.error");
        return "login";
    }

    //推出
    @GetMapping("/logout")
    public  String logout(HttpSession session){
        session.removeAttribute("loginAccount");
        return  "redirect:/login.html";
    }

}
